﻿@{
    ViewBag.Title = "库连接管理";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = request('keyValue');
    $(function () {
        initControl();
    })
    //初始化控件
    function initControl() {
        //库类型
        var $dbtype = $("#F_DbType")
        $dbtype.ComboBox({
            url: "../../SystemManage/DataItemDetail/GetDataItemListJson",
            param: { EnCode: "DbType" },
            id: "F_ItemValue",
            text: "F_ItemName",
            height: "200px",
            description: "==请选择=="
        });
        $dbtype.bind("change", function () {
            var value = $(this).attr('data-value');
            $("#F_Version").ComboBox({
                url: "../../SystemManage/DataItemDetail/GetSubDataItemListJson",
                param: { EnCode: "DbVersion", ItemValue: value },
                id: "F_ItemValue",
                text: "F_ItemName",
                height: "200px",
                description: "==请选择=="
            });
        });
        //库版本
        $("#F_Version").ComboBox({
            description: "==请选择=="
        });
        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../SystemManage/DataBaseLink/GetFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#form1").SetWebControls(data);
                    $('#F_DbType').trigger("change");
                    $("#F_Version").ComboBoxSetValue(data.F_Version);
                }
            });
        }
    }
    //保存表单
    function AcceptClick() {
        if (!$('#form1').Validform()) {
            return false;
        }
        var postData = $("#form1").GetWebControls(keyValue);
        $.SaveForm({
            url: "../../SystemManage/DataBaseLink/SaveForm?keyValue=" + keyValue,
            param: postData,
            loading: "正在保存数据...",
            success: function () {
                $.currentIframe().$("#gridTable").trigger("reloadGrid");
            }
        })
    }
</script>
<div style="margin-top: 20px; margin-right: 30px;">
    <table class="form">
        <tr>
            <th class="formTitle">库类型<font face="宋体">*</font></th>
            <td class="formValue">
                <div id="F_DbType" type="select" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">库版本<font face="宋体">*</font></th>
            <td class="formValue">
                <div id="F_Version" type="select" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">库名称<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="F_DBName" type="text" class="form-control" placeholder="请输入名称" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">库别名<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="F_DBAlias" type="text" class="form-control" placeholder="请输入别名" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">连接地址<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="F_DbConnection" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">备注
            </th>
            <td class="formValue">
                <textarea id="F_Description" class="form-control" style="height: 70px;"></textarea>
            </td>
        </tr>
    </table>
</div>

